package php.code.statements;

import php.code.Sequence;
import php.code.instructions.Instruction;

/**
 * Created by nuno-rafael-figueiredo on 25-05-2014.
 */
public class If extends Statement{
    private static final String PATTERN = "if(%s)";
    private final Instruction condition;

    public If(Instruction condition, Instruction... consequence) {
        this.condition = condition;

        for(Instruction instruction : consequence)
            block.add(instruction);
    }

    @Override
    protected boolean useBrackets() {
        return block.content.elements.size() > 1;
    }

    @Override
    protected String getSignature() {
        return String.format(PATTERN, condition);
    }

    public Sequence getConsequence() {
        return block.content;
    }
}
